<template>
    <div class="escorts">
        <van-nav-bar title="就医陪诊" left-text="返回" left-arrow @click-left="onClickLeft" class="nav" />
        <img src="/public/escort.jpg" class="top_img">
        <div class="con">
            <div class="escort_detail" v-for="(item, i) in serviceData" :key="i"
                @click="handleConClick(item.service_item, item.service_price)">
                <img :src="Images[i]" class="img_detail">
                <h3 class="escort_item">{{ item.service_item }}</h3>
                <span class="escort_dec">{{ item.service_introduction }}</span>
                <div class="escort_right">
                    <span class="escort_price">￥{{ item.service_price }}</span>元/天
                </div>
            </div>
        </div>
    </div>
</template>
<script setup>
import { ref, reactive, onMounted } from 'vue';
import http from '../http';
import { useRouter } from 'vue-router';

const router = useRouter()
let serviceData = ref('')

const Images = [
    "http://mms2.baidu.com/it/u=1297891964,3964858050&fm=253&app=138&f=JPEG?w=60&h=60",
    "http://mms0.baidu.com/it/u=135501046,4290240595&fm=253&app=138&f=PNG?w=72&h=72",
    'http://mms0.baidu.com/it/u=278335649,2632296390&fm=253&app=138&f=PNG?w=130&h=130',
    'https://bpic.588ku.com/element_origin_min_pic/19/03/06/a2c2f75b9aa94439a20850d9ba76245e.jpg',
];
const onClickLeft = () => history.back();
onMounted(() => {
    http.get('/patient/company_services/').then(res => {
        console.log("就医陪诊信息", res.data.service);
        serviceData.value = res.data.service;
        console.log('<<<', serviceData.value);
    }).catch(error => {
        console.log(error)
    })
})


const serviceItemToRouteMap = {
    "尊享VIP陪诊": "/enjoyvipescort",
    "代办买药": "/buymedicine",
    "全程陪诊": "/fullconsultation",
    "专享陪诊": "/exclusivecompany",
};

const handleConClick = (serviceItem, servicePrice) => {
    const routePath = serviceItemToRouteMap[serviceItem];
    if (routePath) {
        router.push({
            path: routePath,
            query: {
                serviceItem: serviceItem,
                servicePrice: servicePrice
            }
        });
    } else {
        console.log(`未配置对应路由的服务项目: ${serviceItem}`);
    }
};


</script>
<style scoped>
.escorts {
    position: relative;
    height: 100%;
    background-color: rgb(245, 245, 245);
}

.top_img {
    width: 100%;
    height: 200px;
}

.escort_detail {
    position: relative;
    background-color: #fff;
    margin: 5% 5% 0;
    width: 90%;
    height: 80px;
    border-radius: 10px;
    font-size: 12px;
}

.img_detail {
    position: absolute;
    width: 40px;
    height: 30px;
    left: 2%;
    margin-top: 4%;
    border-radius: 10px;
}

.escort_item {
    position: absolute;
    left: 18%;
    top: 0;
    font-weight: 700;
}

.escort_right {
    position: absolute;
    right: 5%;
    top: 10%;
    font-weight: 700;
    font-size: 16px;
    color: rgb(247, 114, 19);
}

.escort_dec {
    position: absolute;
    left: 18%;
    top: 50%;
}

.escort_price {
    font-weight: 900;
    font-size: 18px;
}
</style>